import React from 'react'
import { View, AsyncStorage, ScrollView, Text } from 'react-native'
import { API, WINDOW } from '../../Services'
import styles from '../Styles/CommonContainerStyles'
import { Button, WingBlank, WhiteSpace, List } from '@ant-design/react-native'
const ListItem = List.Item

class SetScreen extends React.Component {

    constructor(props) {
        super(props)
        this.state = {
        }
    }

    componentDidMount() {
    }

    _doLoginOut = () => {
        AsyncStorage.removeItem('loginUser', (error) => {
            API.api.setHeaders({ 'xx-Token': '' })
            WINDOW.loginUser = null
            WINDOW.showToastSuccess('退出登录成功！')
            this.props.route.params?.callBack()
            this.props.navigation.goBack()
        })
    }

    _render_info() {
        return (
            <View>
                <List>
                    <ListItem arrow="horizontal" multipleLine onPress={() => { this.props.navigation.navigate('GuanYu') }}>关于建筑派</ListItem>
                    <ListItem arrow="horizontal" multipleLine onPress={() => { this.props.navigation.navigate('WebView', { type: 1 }) }}>用户服务协议</ListItem>
                    <ListItem arrow="horizontal" multipleLine onPress={() => { this.props.navigation.navigate('WebView', { type: 2 }) }}>隐私政策</ListItem>
                    <ListItem arrow="horizontal" multipleLine onPress={() => { this.props.navigation.navigate('Kefu') }}>客服</ListItem>
                    <ListItem arrow="horizontal" multipleLine onPress={() => { this.props.navigation.navigate('FanKui') }}>反馈意见</ListItem>
                </List>
            </View>
        )
    }

    _renderFooter() {
        return (
            <View style={{ marginHorizontal: 15, marginTop: 90 }}>
                <Button type='primary' onPress={() => this._doLoginOut()}>退出登录</Button>
                <Text style={{ fontSize: 10, marginTop: 10 }}>版本号:V{WINDOW.appVersion}</Text>
            </View>
        )
    }

    render() {
        return (
            <ScrollView style={[styles.container]}>
                {this._render_info()}
                {this._renderFooter()}
            </ScrollView>
        )
    }
}

export default SetScreen
